package com.hontech.bread.ui.parts

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bread.R
import com.hontech.bread.device.heatOff
import com.hontech.bread.device.heatOn
import com.hontech.bread.ui.dialog.runProg
import com.hontech.bread.utils.onClick
import com.hontech.bread.utils.stringById

class HeatCtrlParts(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_heat_ctrl, this)
        val btnOn = view.findViewById<Button>(R.id.id_heat_btn_on)
        val btnOff = view.findViewById<Button>(R.id.id_heat_btn_off)

        btnOn.onClick {
            runProg(stringById(R.string.t1733460848_414), stringById(R.string.t1733460848_415)) {
                heatOn()
            }
        }

        btnOff.onClick {
            runProg(stringById(R.string.t1733460848_416), stringById(R.string.t1733460848_417)) {
                heatOff()
            }
        }
    }
}

